package com.health.viewscontrols.medical.adapter;

import android.support.annotation.Nullable;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.health.viewscontrols.medical.base.DeviceEnum;
import com.nova.health.ble.R;

import java.util.List;

public class MedicalAdapter extends BaseQuickAdapter<DeviceEnum, BaseViewHolder> {

    private boolean showHide;

    public MedicalAdapter(int layoutResId, @Nullable List<DeviceEnum> data,boolean showHide) {
        super(layoutResId, data);
        this.showHide = showHide;
    }

    @Override
    protected void convert(BaseViewHolder helper, DeviceEnum item) {
        helper.setText(R.id.tv_title,item.getDeviceName());

        ImageView iv_item_bg = helper.getView(R.id.iv_icon);
        LinearLayout ll_background = helper.getView(R.id.ll_background);
        iv_item_bg.setBackgroundResource(item.getIcon());
        ll_background.setBackgroundResource(item.getBg_url());
        if (showHide) {
            ImageView iv_show_hide = helper.getView(R.id.iv_show_hide);
            iv_show_hide.setVisibility(View.VISIBLE);
            if (item.isShow()) {
                iv_show_hide.setBackgroundResource(R.drawable.icon_ble_show);
            } else {
                iv_show_hide.setBackgroundResource(R.drawable.icon_ble_hide);
            }
        }
    }
}
